import { patch } from "../../patch"
import { invokeLifeCycleHook } from "src/lifeCycle"
import type { ComponentInstance, vnode } from "../../../types"


class ReactiveEffect {
  constructor(effect:Function) {

  }
}

export function setupRenderEffect(instance:ComponentInstance) {  
  const componentUpdateFn = ()=>{
    const {render, proxy} = instance

    if(instance.isMounted) {
      const { bu, u } = instance.life
      
    } else {
      const { bm, m } = instance.life

      invokeLifeCycleHook(bm)

      const subTree = render?.call(proxy) as unknown as vnode
  
      patch(subTree, document.body)

      invokeLifeCycleHook(m)

      instance.isMounted = true
    }
  }

  instance.update = componentUpdateFn

  // first render view
  instance.update()
}
